package com.test.mybatis.dao;

import com.test.mybatis.entities.Employee;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/11/6 10:09
 */
public interface EmployeeMapper {
    public Employee getEmpById(Integer id);

    public boolean addEmp(Employee employee);

    public boolean addEmpEnum(Employee employee);

    public Long updateEmp(Employee employee);

    public boolean deleteEmpById(Integer id);

    public Employee getEmpByIdAndLastName(@Param("id") Integer id, @Param("lastName") String lastName);

    public Employee getEmpByMap(Map<String, Object> map);

    public List<Employee> getEmpsByLastNameLike(@Param("lastName") String lastName);

    //返回一条记录的map，key就是列名，值就是对应的值
    public Map<String, Object> getEmpByIdReturnMap(Integer id);

    //多条记录封装成一个map, Map<integer,Employee>键是这条记录的主键，值是封装后的java bean
    //使用@MapKey("id")告诉mybatis封装这个map的时候指定哪个属性作为key
    @MapKey("id")
    public Map<Integer, Employee> getEmpByLastNameLikeReturnMap(String lastName);

    List<Employee> getEmpsByDeptId(Integer deptId);

    public List<Employee> getEmps();


}
